# core driver files
CFILES = xbmd.c sysxbmd.c
HFILES = sysxbmd.h


# 驱动名
DRIVER_NAME = xbmd
# 节点名
NODE_NAME = /dev/xbmd
# 内核版本
KVERS = $(shell uname -r)

# kenel modules
TARGET = $(DRIVER_NAME).ko

obj-m += $(DRIVER_NAME).o

# specify flags for the module compilation
#EXTRA_CFLAGS = -g - O0

# set the kernel path
KERNDIR := /lib/modules/$(KVERS)/build

# set the install path
#INSTDIR := /lib/modules/$(KVERS)/kernel/drivers/serial/$(DRIVER_NAME)
INSTDIR := /lib/modules/$(KVERS)/kernel/drivers/xbmd/$(DRIVER_NAME)

# set the current path
CURDIR := $(shell pwd)

defualt :
	make -C $(KERNDIR) M=$(CURDIR) modules

install : defualt
	# remove all old versions of the driver
	#find /lib/modules/$(KVERS) -name $(TARGET) -exec rm -f {} \; || true
	#find /lib/modules/$(KVERS) -name $(TARGET).gz -exec rm -f {} \; || true
	#install -D -m 644 $(TARGET) $(INSTDIR)/$(TARGET)
	
	insmod $(TARGET)
	#mknod /dev/canDev_0 c 250 0
	#mknod /dev/canDev_1 c 250 1

uninstall :
	#if [ -e $(INSTDIR)/$(TARGET) ]; \
	#then rm -f $(INSTDIR)/$(TARGET); \
	#fi
	#/sbin/depmod -a
	#if [ -e $(MANDIR)/man$(MANSECTION)/$(MANFILE).gz ]; \
	#then rm -f $(MANDIR)/man$(MANSECTION)/$(MANFILE).gz ; \
	#fi

	rmmod $(DRIVER_NAME)	

	
clean :
	make -C $(KERNDIR) M=$(CURDIR) clean

